<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	<meta charset="UTF-8">
	<title>接口异常日志管理</title>
	<style type="text/css">
        #fm{
            margin:0;
            padding:10px 50px;
        }
        .ftitle{
            font-size:14px;
            font-weight:bold;
            padding:5px 0;
            margin-bottom:10px;
            border-bottom:1px solid #ccc;
        }
        .fitem{
            margin-bottom:5px;
        }
        .fitem label{
            display:inline-block;
            width:80px;
        }
        .fitem input{
            width:160px;
        }
    </style>
	
	<link rel="stylesheet" type="text/css" href="<%=path %>/js/jquery-easyui-1.4.4/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=path %>/js/jquery-easyui-1.4.4/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="<%=path %>/js/jquery-easyui-1.4.4/demo/demo.css">
	<script type="text/javascript" src="<%=path %>/js/jquery-easyui-1.4.4/jquery.min.js"></script>
	<script type="text/javascript" src="<%=path %>/js/jquery-easyui-1.4.4/jquery.easyui.min.js"><script>
	<script  type="text/javascript">
		
	</script>
</head>
  
  <body>
    <h2>接口异常日志管理</h2>
    <div style="margin:20px 0;"></div>
	<div class="easyui-layout" style="width:100%;height:92%;">
		 <div data-options="region:'north'" style="height:50px;width:100%">
		 	<form id="searchForm">
		 	  	<div style="float: left; padding:20px 0 0 20px; ">   
			        <label for="ename">电商名称:</label>   
			        <input id="s_ename"  name="ename" class="easyui-combobox" data-options="valueField:'value',textField:'text',data:[{'value':'JD','text':'京东'},{'value':'SN','text':'苏宁'},{'value':'DL','text':'得力'},{'value':'XY','text':'西域'}]"/>
			    </div>   
		 		<div style="float: left; padding:20px 0 0 20px; ">   
			        <label for="orderId">订单号:</label>
			        <input class="easyui-validatebox" type="text" name="orderId"  id="s_orderId" />   
			    </div>   
			    <div style="float: left; padding:20px 0 0 20px; ">
			        <label for="createDate">日期(至今):</label>
			        <input id="s_createDate"  name="createDate" class="easyui-datebox" />
			    </div>
			    <div style="float: left;padding:20px 0 0 20px;">   
			        <input class="easyui-validatebox" type="button" value="查询"  onclick="searchLog()"/>
			        <input class="easyui-validatebox" type="button" value="重置"  onclick="clearLog()"/>
			    </div>
		 	</form>
		 </div>
		<!--<div data-options="region:'south',split:true" style="height:50px;"></div>
		<div data-options="region:'east',split:true" title="East" style="width:100px;"></div>
		<div data-options="region:'west',split:true" title="West" style="width:100px;"></div>-->
		<div data-options="region:'center',title:'',iconCls:'icon-ok'">
			<table class="easyui-datagrid" 
			  		 id="logList"
					 toolbar="#toolbar"
					 pagination="true"
					 rownumbers="true"
					data-options="method:'post',border:false,singleSelect:false,fit:true,fitColumns:true">
			</table>
			<div id="toolbar">
				<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="viewLog()">查看</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="removeLog()">删除</a>
			</div>
		</div>
	</div>
	
	<div id="log_win" class="easyui-window"  closed="true" style="padding:10px 0 0 10px; ">
			<form id="logForm"  method="post" >
			   	<div class="fitem">
			   		<label style="text-align:right" >电商:</label>
					<input id="emName" name="emName" class="easyui-validatebox" style="width:440px" readonly="readonly" />
				</div>
				<div class="fitem">
					<label style="text-align:right">订单号:</label>
					<input id="orderId" name="orderId" class="easyui-validatebox" style="width:440px" readonly="readonly"/>
				</div>
				<div class="fitem">
					<label style="text-align:right">创建日期:</label>
					<input id="createDate" name="createDate" class="easyui-validatebox" style="width:440px" readonly="readonly"/>
				</div>
				<div class="fitem">
					<label style="text-align:right">异常信息:</label>
					<input id="errorMsg" class="easyui-textbox" name="errorMsg" data-options="multiline:true" style="height:100px;width:440px" readonly="readonly" />
				</div>
				<div class="fitem">
					<label style="text-align:right">订单内容:</label>
					<input id="order_info" class="easyui-textbox" name="order_info" data-options="multiline:true" style="height:150px;width:440px"  readonly="readonly"/>
				</div>
			</form>
			<div id="emp_buttons" align="center">
		        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$win.window('close')" >关闭</a>
			</div>
	</div>
	<script type="text/javascript">
		function searchLog(){
			var ename = $("#s_ename").combobox('getValue');
			var orderId = $("#s_orderId").val();
			var createDate = $("#s_createDate").datebox('getValue');
			$('#logList').datagrid('load',{ename:ename,orderId:orderId,createDate:createDate});
		}
		
		function clearLog(){
				$('#searchForm').form('clear');
				searchLog();
		}
		
		function removeLog(){
			var rows = $('#logList').datagrid('getChecked');
			if(rows.length>0){
				$.messager.confirm('Confirm','确定要删除吗?',function(r){
					var ids = new Array();
					for(i=0;i<rows.length;i++){
						ids[i] = rows[i].id;
					}
					ids = ids.join(",");
					$.post('removeLog',{ids:ids},function(result){
	                    if (result.flag==1){
	                        $('#logList').datagrid('reload');
	                    } else {
	                        $.messager.alert("提示",result.errorMsg);
	                    }
	                },'json');
				})
			}else{
            	$.messager.alert("提示","请选择需要删除的信息！");
            }
		}
		
		function viewLog(){
			var row = $('#logList').datagrid('getSelected');
            if (row){
                $win.window('open').dialog('setTitle','查看日志信息');
                var a = JSON.stringify(row.orderInfo);
                row.order_info = a;
                $('#logForm').form('load',row);
            }else{
            	$.messager.alert("提示","请选择需要一条需要查看的信息！");
            }
		}
		
		$('#logList').datagrid({
				title:'异常日志列表',
				url:'getList',
				pageSize:'20',
				fit:true,
				method:'post',
				striped: true,
				columns: [  
	            [   
					{field:'ck',checkbox:true},
	            	{field:'id', title: 'ID', width: 180, hidden:'true',align: "left"},
	                {field:'emName', title: '电商名称', width: 180, align: "left"},
	                {field: 'orderId', title: '订单号', width: 180, align: "right"},
	                {field: 'errorMsg', title: '异常信息', width: 180, align: "left"},
	                {field: 'createDate', title: '创建日期', width: 180, align: "right"}
	            ]  
	        ],
	        onDblClickRow:function(rowIndex, rowData){
	        	$win.window('open').dialog('setTitle','查看日志信息');
                var a = JSON.stringify(rowData.orderInfo);
                rowData.order_info = a;
                $('#logForm').form('load',rowData);
	        }
		});
		//设置分页控件  
		$(function () {
			var p = $('#logList').datagrid('getPager');  
	    $(p).pagination({  
	        pageSize: 20,//每页显示的记录条数，默认为10  
	        beforePageText: '第',//页数文本框前显示的汉字  
	        afterPageText: '页    共 {pages} 页',  
	        displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'  
	    });
		});
		
		var $win;
		$win = $('#log_win').window({
		    title: '查看日志信息',
		    width: 600,
		    height: 420,
		    top: ($(window).height() - 350) * 0.5,
		    left: ($(window).width() - 450) * 0.5,
		    shadow: true,
		    modal: true,
		    iconCls: 'icon-add',
		    closed: true,
		    minimizable: false,
		    maximizable: false,
		    collapsible: false
		});
		
		$(document).ready(function() {
			document.onkeydown = function(e){
				if(e.keyCode===13){
					searchEmp();
				}
			};
		});
	</script>
  </body>
</html>
